<template>
	<view class=" p-l-20 p-r-20 p-t-24">
		<view class="top-con bg-white br12">
			感谢您对货司拉的支持！您的宝贵意见将成为我们
			日后工作的重要参考。
			如遇问题需客服协助处理，请联系在线客服，以便
			我们及时跟进。
		</view>
		<view class="m-t-16 bg-white br12 p-l-20 p-r-20 p-t-28 p-b-28">
			<view class="">
				<view class="tit p-b-20">
					我的意见是关于：
				</view>
				<view class="">
					<u-radio-group v-model="value" active-color="#df563b">
						<u-radio 
							@change="radioChange" 
							v-for="(item, index) in typeList" :key="index" 
							:name="item.id"
						>
							{{item.name}}
						</u-radio>
					</u-radio-group>
				</view>
			</view>
			<view class="m-t-32">
				<view class="tit p-b-20">
					我的意见/建议是：
				</view>
				<view class="">
					<u-input 
					v-model="details" 
					type="textarea" 
					placeholder="任何意见与建议，请在这里告诉我们吧~订单相关问题，可备注订单编号，或订单日期与订单起/终点信息。也可以在下方上传订单截图。"
					:border="true"
					height="200"
					></u-input>
				</view>
			</view>
			<view class="m-t-32">
				<view class="tit p-b-20">
					如有相关系统截图、视频，可点击上传：
				</view>
				<view class="">
					<u-upload ref="uUpload" :show-progress="false" :header="{token: $store.getters.token}"
						:max-count="10" width="150" height="150" :action="action" upload-text="上传图片"
						@on-success="onSuccess"  @on-remove="onRemove" />
				</view>
			</view>
			<!-- <view class="">
				<u-field label="反馈标题" label-width="160" placeholder="请输入标题" :border-bottom="false"
				v-model="title"
					required  />
			</view>
			<view class="">
				<u-field label="反馈内容" label-width="160" placeholder="请输入内容" :border-bottom="false"
				type="textarea"
				v-model="details"
					required  />
			</view>
			<view class="apply-form-item">
				<u-field label="相关图片" label-width="160" placeholder="请上传相关图片" :border-bottom="false"
					required disabled />
				<view>
					
				</view>
			</view> -->
		</view>
		
		<view style="padding: 30rpx 20rpx 30rpx 20rpx;" >
			<button type="primary" size="lg" class="br10" @tap="onSubmit">提交</button>
		</view>
	</view>
</template>

<script>
	import {advice,adviceSelect} from '@/api/user'
	import {
		baseURL
	} from '@/config/app'
	export default {
		data() {
			return {
				category_id:"",
				details:'',
				files:[],
				action: baseURL + '/api/file/formimage',
				typeList:[]
			}
		},
		onLoad() {
			this.adviceSelectFun();
		},
		methods: {
			radioChange(e){
				console.log(e)
				this.category_id = e;
			},
			adviceSelectFun(){
				adviceSelect().then(res=>{
					this.typeList = res.data.lists
				})
			},
			onSuccess(e) {
				this.files.push(e.data.uri)
			},
			onRemove(index) {
				this.files.splice(index, 1)
				console.log(index)
			},
			onSubmit(){
				
				let {category_id,details,files} = this;
				
				if(category_id==''){
					this.$toast('请选择关于的意见')
					return 
				}
				
				advice({
					category_id,details,files
				}).then(res=>{
					if(res.code==1){
						this.title = '';
						this.details = '';
						this.$toast({
							title:'提交成功'
						})
						
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.top-con{
		padding: 32upx 40upx;
	}
</style>
